﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace YAPL.Util {
	public static class EncodingExtensions {
		public static string DecodeString(this Encoding trg, string value, Encoding src) {
			Decoder dec = src.GetDecoder();
			byte[] ba = trg.GetBytes(value);
			int len = dec.GetCharCount(ba, 0, ba.Length);
			char[] ca = new char[len];
			dec.GetChars(ba, 0, ba.Length, ca, 0);
			return new string(ca);
		}
	}
}
